package com.springboot.controller;

import com.springboot.dto.AssistantMineView;
import com.springboot.model.UserLoginForm;
import com.springboot.service.AssistantMessageListService;
import com.springboot.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 本控制台用于助理显示我的界面显示
 */
@Controller
public class AssistantMine {
    @Autowired
    UserLoginService userLoginService;
    @Autowired
    AssistantMessageListService assistantMessageListService;

    @CrossOrigin
    @RequestMapping(value = "/assistantGetSelfInfo")
    public @ResponseBody
    String showAssistantMine(@RequestParam("username") String tel){
        System.out.println("开始我的界面展示"+tel);
        try{
            UserLoginForm userLoginForm=userLoginService.findUserByTel(tel);
            Integer assistantId=userLoginForm.getUserId();
            String logoLink=userLoginForm.getLogoLink();
            int a=assistantMessageListService.getNoReadMessageNum(assistantId);
            AssistantMineView assistantMineView=new AssistantMineView(logoLink,a);
            System.out.println(a+"|||"+assistantMineView.toString1());
            return assistantMineView.toString1();
        }
        catch (Exception e)
        {
            return "False";
        }

    }
}
